package org.springframework.web.servlet.ajax.json;

import java.util.List;
import java.util.Map;

//CHUCK TODO  More documentation.
public interface JsonAjax {

	public static final String LIST_DELIMITER = ",";

	public void setPartialsCore(PartialsCore partialsCore);

	public void writeJsonRedirect(String relativePath);
	
	public void addJavascript(String javascript);
	
	public void addJavascript(String viewName, Map modelMap);

	/**
	 * Note that keys and viewNames can each either be a simple String or a comma
	 * delimted String such as "view1;view2;view3" that will internally be resolved
	 * to a list == ["view1", "view2", "view3"].  Both keys and viewNames must be of the same
	 * length.  Of course, no comma in either will in essence be resolved to a list
	 * of size 1 (i.e., "view1" resolves to ["view1"]
	 * @param keys  will eventually be the keys (== attribute names) in a JSON object
	 * @param viewNames are the names of the views to be rendered.
	 * @param modelMap
	 * @return a Map where the keys are the argument keys, and the  values
	 * are rendered html content (or anything else that the view names were rendered to,
	 * including possibly javascript.)
	 */
	public Map addPartials(String keys, String viewNames, Map modelMap);

	public Map addPartials(List<String> keys, List<String> viewNames,
			Map modelMap);

	//Can be used both to get the map and to add to it.
	//This is info that we expect will be serialized, and of course it
	//may be that client code takes this map and does the json serialization itself.
	public Map getMap();

	//For now we'll assume that we've already got the map, that the developer has
	//added to it if neccesarry by calling getMap(), and wants us to use that map.
	//Of course the developer could just getMap() and use his own json serializtion
	//mechanism.
	public String toJson();

	public void writeJson();

}